package com.windows;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;

import com.base.ChangOwnPssword;
import com.manage.jpan.StudentMan;
import com.manage.jpan.TeacherMan;
import com.teacher.jpan.TstudentMan;
import com.tools.EasyCode;
import com.tools.Table;
import com.tools.Tools;



public class TeacherManWindows {
JFrame jFrame=new JFrame();
	
	final int WIDTH=1022;
	final int HEIGHT=670;
	
	String account;
	public TeacherManWindows(String account) {
		this.account=account;

		init();	
		jFrame.setResizable(false);//窗口是否可变
		jFrame.setVisible(true);//窗口是否可见
		jFrame.setDefaultCloseOperation(jFrame.DISPOSE_ON_CLOSE);//设置默认关闭方式
		jFrame.validate();//让组件生效
	}
	
	void init() {
		
		//设置窗口在屏幕中间  并设置大小
		Tools.setWindowPos(WIDTH, HEIGHT, jFrame);
		EasyCode.setTileIcon(jFrame);//设置标题和图标
		jFrame.setLayout(new FlowLayout(FlowLayout.CENTER));
		
		JPanel jPanel=new JPanel();//定义一个盘子
		jPanel.setLayout(new FlowLayout(FlowLayout.CENTER));//设置居中
		jPanel.setPreferredSize(new Dimension(WIDTH-800,HEIGHT-40));//设置大小
		jFrame.add(jPanel);//添加盘子
		jPanel.setBackground(new Color(255,255,255));
		

		JLayeredPane jPanel1=new JLayeredPane();//定义一个层叠窗格
		jPanel1.setLayout(new FlowLayout(FlowLayout.CENTER));
		jPanel1.setPreferredSize(new Dimension(WIDTH-(WIDTH-800)-40,HEIGHT-40));
		jFrame.add(jPanel1);
		jPanel1.setBackground(Color.CYAN);
		//______________________
		Box boxHBox=Box.createVerticalBox();//建立一个垂直的盒子 可以垂直放东西
		jPanel.add(boxHBox);//向第一个标签添加 这个
		
		//实现功能 修改个人密码  查看个人信息（增删改查 老师个人信息 ）

		
		JButton jButton2=new JButton("学生成绩管理");
		boxHBox.add(jButton2);
		boxHBox.add(Box.createVerticalStrut(20));
		
		JButton jButton3=new JButton("修改个人密码");//定义一个按钮
		boxHBox.add(jButton3);//添加到盒子
		boxHBox.add(Box.createVerticalStrut(20));//设置垂直间隔
		
		
		
		
		TstudentMan student=new 	TstudentMan(WIDTH-(WIDTH-800)-40,HEIGHT-40);
		jPanel1.add(student);

		ChangOwnPssword changOwnPssword=new 	ChangOwnPssword(WIDTH-(WIDTH-800)-40,HEIGHT-40,account,"2");
		jPanel1.add(changOwnPssword);
		
		
	
		
		jButton2.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
				jPanel1.moveToFront(student);
				SwingUtilities.updateComponentTreeUI(student);//添加或删除组件后,更新窗口
			}
		});
		
		jButton3.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
				jPanel1.moveToFront(changOwnPssword);
				SwingUtilities.updateComponentTreeUI(changOwnPssword);//添加或删除组件后,更新窗口
				
			}
		});
		
		
	}
}
